package com.yun.zf.search.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yun.zf.common.app.domain.ZfCommunity;
import com.yun.zf.common.app.dto.detail.CommunityNearByDto;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 社区表 Mapper 接口
 * </p>
 *
 * @author cj
 * @since 2021-01-29
 */
@Mapper
public interface CommunityMapper extends BaseMapper<ZfCommunity> {



    @Select("<script>" +
            " SELECT  zc.id, zc.province_code ,zc.city_code,zc.region_name,zc.street_name,zc.community_name,zc.cty_build_year,zc.address,zc.brand_reason,zc.is_hot_c,zc.is_brand_c ,cp.url  from zf_community zc \n" +
            "  LEFT JOIN (SELECT community_id ,url from zf_community_picture p WHERE  p.type=0 ) cp on zc.id =cp.community_id  " +
            "WHERE   zc.id IN " +
            "<foreach item='item' index='index' collection='ids' open='(' separator=',' close=')' > " +
            "  #{item} " +
            "  </foreach> " +
            "</script>")
    List<CommunityNearByDto> getBasicCommunity(@Param("ids") List<Long> ids);

}
